package com.service.order;

import com.common.ErrorCodeEnum;
import com.common.emums.DataStatus;
import com.common.exception.BusinessException;
import com.common.utils.StringUtils;
import com.core.springSecurity.common.SecurityUtils;

import com.dao.order.OrderRepairRecordInfoMapper;
import com.model.domain.order.GetOrderRepairRecordInfoDO;
import com.model.domain.order.GetOrderRepairRecordOverviewDO;
import com.model.pojo.order.OrderRepairRecordInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageHelper;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;


/**
 * @Author: zql
 * @Description: 维修订单记录服务
 * @Data: 2023-09-09
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class OrderRepairRecordInfoService {
    private final OrderRepairRecordInfoMapper orderRepairRecordInfoMapper;

    public List<OrderRepairRecordInfo> getPageList(GetOrderRepairRecordInfoDO getOrderRepairRecordInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getOrderRepairRecordInfoDO.getPage(),getOrderRepairRecordInfoDO.getPageSize(),getOrderRepairRecordInfoDO.getSortRow()+getOrderRepairRecordInfoDO.getSortOrder());
        return orderRepairRecordInfoMapper.selectList(getOrderRepairRecordInfoDO);
    }

    public List<OrderRepairRecordInfo> getList(GetOrderRepairRecordInfoDO getOrderRepairRecordInfoDO){
        return orderRepairRecordInfoMapper.selectList(getOrderRepairRecordInfoDO);
    }
    public List<OrderRepairRecordInfo> getAllList(GetOrderRepairRecordInfoDO getOrderRepairRecordInfoDO){
        PageHelper.clearPage();
        PageHelper.orderBy(getOrderRepairRecordInfoDO.getSortRow()+getOrderRepairRecordInfoDO.getSortOrder());
        return orderRepairRecordInfoMapper.selectList(getOrderRepairRecordInfoDO);
    }

    /**
     * 统计当天维修数据
     * @param carId
     * @param time
     * @return
     */
    public List<GetOrderRepairRecordOverviewDO> selectByCarIdCount(Long carId, String time){
        return orderRepairRecordInfoMapper.selectByCarIdCount(carId,time);
    }
}
